{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Challenge 1: Square roots\n",
    "\n",
    "Fill in the blanks in the program below so that it prints the square root for each number in  `squares`. You can get the square root of a number like this:\n",
    "\n",
    "    number ** .5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "squares = [1, 4, 9, 16, 25]\n",
    "\n",
    "for s in squares:\n",
    "    print(s ** .5)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Challenge 2: Practice Accumulating\n",
    "\n",
    "Fill in the blanks in each of the programs below\n",
    "to produce the indicated result."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Total length of the strings in the list: [\"red\", \"green\", \"blue\"] => 12\n",
    "total = 0\n",
    "for word in [\"red\", \"green\", \"blue\"]:\n",
    "    total = total + len(word)\n",
    "print(total)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# List of word lengths: [\"red\", \"green\", \"blue\"] => [3, 5, 4]\n",
    "lengths = []\n",
    "for word in [\"red\", \"green\", \"blue\"]:\n",
    "    lengths.append(len(word))\n",
    "print(lengths)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Concatenate all words: [\"red\", \"green\", \"blue\"] => \"redgreenblue\"\n",
    "words = [\"red\", \"green\", \"blue\"]\n",
    "result = \"\"\n",
    "for c in words:\n",
    "    result += c\n",
    "print(result)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create acronym: [\"red\", \"green\", \"blue\"] => \"RGB\"\n",
    "# write the whole thing\n",
    "\n",
    "ac = \"\"\n",
    "for c in words:\n",
    "    ac += c[0].upper()\n",
    "print(ac)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Challenge 3: Multiple Operations\n",
    "\n",
    "Below is a list of presidents. Create a new list that contains only the last name of each president.\n",
    "\n",
    "(HINT: Look at string methods!)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "presidents_full = [\"George Washington\", \"John Adams\", \"Thomas Jefferson\", \"James Madison\", \"James Monroe\", \\\n",
    "        \"John Quincy Adams\", \"Andrew Jackson\", \"Martin Van Buren\", \"William Henry Harrison\", \"John Tyler\", \\\n",
    "        \"James K. Polk\", \"Zachary Taylor\", \"Millard Fillmore\", \"Franklin Pierce\", \"James Buchanan\", \\\n",
    "        \"Abraham Lincoln\", \"Andrew Johnson\", \"Ulysses S. Grant\", \"Rutherford B. Hayes\", \"James A. Garfield\", \\\n",
    "        \"Chester A. Arthur\", \"Grover Cleveland\", \"Benjamin Harrison\", \"Grover Cleveland\", \"William McKinley\", \\\n",
    "        \"Theodore Roosevelt\", \"William Howard Taft\", \"Woodrow Wilson\", \"Warren G. Harding\", \"Calvin Coolidge\", \\\n",
    "        \"Herbert Hoover\", \"Franklin D. Roosevelt\", \"Harry S. Truman\", \"Dwight D. Eisenhower\", \"John F. Kennedy\", \\\n",
    "        \"Lyndon B. Johnson\", \"Richard Nixon\", \"Gerald Ford\", \"Jimmy Carter\", \"Ronald Reagan\", \"George H. W. Bush\", \\\n",
    "        \"Bill Clinton\", \"George W. Bush\", \"Barack Obama\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "last_names = []\n",
    "for p in presidents_full:\n",
    "    l_name = p.split()[-1]\n",
    "    last_names.append(l_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "last_names"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Challenge 4: Range\n",
    "\n",
    "Using `range` and a for loop, calculate the factorial of 42 (the product of all integers up to and including 42)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "factorial = 1\n",
    "for num in range(1, 43):\n",
    "    factorial *= num\n",
    "\n",
    "print(factorial)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
